<template>
  <a-modal
    title="商户组别限额管理详情"
    v-model="show"
    :maskClosable="false"
    :width="1050"
    placement="right"
    :closable="true"
    @cancel="onClose"
    :footer="null"
    :visiable="bankLevelManagerInfoVisiable"
  >
    <a-form :form="form">
      <a-row>限额详情</a-row>
      <a-row>
        <a-col :md="12" :sm="24">
          <a-form-item label="商户组别"
                       v-bind="formItemLayout">
            <a-input v-decorator="['grpDesc',{rules: [{ required: true, message: '必填字段'}]}]" :disabled="true"/>
          </a-form-item>
        </a-col>
        <a-col :md="12" :sm="24">
          <a-form-item label="商户MCC"
                       v-bind="formItemLayout">
            <a-input v-decorator="['industryName',{rules: [{ required: true, message: '必填字段'}]}]" :disabled="true"/>
          </a-form-item>
        </a-col>
        </a-row>
      <a-row>
      <a-col :md="12" :sm="24">
          <a-form-item label="日累计限额"
                       v-bind="formItemLayout">
            <a-input v-decorator="['dayLimitAmt']" :disabled="true"/>
          </a-form-item>
        </a-col>
        <a-col :md="12" :sm="24">
          <a-form-item label='月累计限额'
                       v-bind="formItemLayout">
            <a-input v-decorator="['monthLimitAmt']" :disabled="true"/>
          </a-form-item>
        </a-col>
      </a-row>

      <a-row>借记限额</a-row>
      <a-row>
        <a-col :md="12" :sm="24">
          <a-form-item label="单笔借记限额"
                       v-bind="formItemLayout">
            <a-input v-decorator="['singleLimitLoanMaxAmt']" :disabled="true"/>
          </a-form-item>
        </a-col>
        <a-col :md="12" :sm="24">
          <a-form-item label='日累计借记限额'
                       v-bind="formItemLayout">
            <a-input placeholder="小微商户必填最大1000" v-decorator="['dayLimitLoanAmt']" :disabled="true"/>
          </a-form-item>
        </a-col>
      </a-row>
      <a-row>
        <a-col :md="12" :sm="24">
          <a-form-item label="月累计借记限额"
                       v-bind="formItemLayout">
            <a-input placeholder="小微商户必填最大1000" v-decorator="['monthLimitLoanAmt']" :disabled="true"/>
          </a-form-item>
        </a-col>
      </a-row>

      <a-row>贷记限额</a-row>
      <a-row>
        <a-col :md="12" :sm="24">
          <a-form-item label="单笔贷记限额"
                       v-bind="formItemLayout">
            <a-input v-decorator="['singleLimitCreditMaxAmt']" :disabled="true"/>
          </a-form-item>
        </a-col>
        <a-col :md="12" :sm="24">
          <a-form-item label='日累计贷记限额'
                       v-bind="formItemLayout">
            <a-input v-decorator="['dayLimitCreditAmt']" :disabled="true"/>
          </a-form-item>
        </a-col>
      </a-row>
      <a-row>
        <a-col :md="12" :sm="24">
          <a-form-item label="月累计贷记限额"
                       v-bind="formItemLayout">
            <a-input v-decorator="['monthLimitCreditAmt']" :disabled="true"/>
          </a-form-item>
        </a-col>
      </a-row>

      <br>

    </a-form>

  </a-modal>

</template>
<script>
  const formItemLayout = {
    labelCol: {span: 8},
    wrapperCol: {span: 16}
  }
  export default {
    name: 'BankLevelManagerInfo',

    props: {
      bankLevelManagerInfoVisiable: {
        default: false
      },
      instId: '',
    },
    data() {
      return {
        data: [],
        grpNoData: [],
        bankLevelManagerInfo: {
          visiable: false
        },
        loading: false,
        formItemLayout,
        form: this.$form.createForm(this),
        validateStatus: '',
        // firstValue: {},
        info: {
          infoName: '',
          remark: '',
          menuId: ''
        },
        operatorType: ''
      }
    },
    computed: {
      show: {
        get: function () {
          return this.bankLevelManagerInfoVisiable
        },
        set: function () {
        }
      }
    },
    mounted() {

    },

    methods: {

      filterOption(input, option) {
        return (
          option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
        );
      },


      selectMchntNo(val) {
        this.grpNoData = []
        let param = {}
        if (val) {
          param = {
            q: encodeURIComponent(val + `&${this.instId}`),
            pageSize: 20
          }
          if (val.length >= 5) {
            this.$get('admin/mcmp/bMchntBaseInfo/mchntFormalSelect2List', param).then((r) => {
              let result = r.data.rows
              result.forEach(r => {
                this.grpNoData.push(r);
              })
            })
          }
        } else {
          param = {
            q: encodeURIComponent(`&${this.instId}`),
            pageSize: 20
          }
          this.$get('admin/mcmp/bMchntBaseInfo/mchntFormalSelect2List', param).then((r) => {
            let result = r.data.rows
            result.forEach(r => {
              this.grpNoData.push(r);
            })
          })
        }
      },

      reset() {
        this.loading = false
        this.form.resetFields()
      },
      onClose() {
        this.reset()
        this.$emit('close')
      },

      setBankLevelManagerFormValues ({...info}) {
        let fields = ['grpDesc', 'industryName', 'dayLimitAmt', 'monthLimitAmt', 'singleLimitLoanMaxAmt',
          'dayLimitLoanAmt', 'monthLimitLoanAmt', 'singleLimitCreditMaxAmt', 'dayLimitCreditAmt', 'monthLimitCreditAmt' ]
        Object.keys(info).forEach((key) => {
          if (fields.indexOf(key) !== -1) {
            this.form.getFieldDecorator(key)
            let obj = {}
            obj[key] = info[key]
            this.form.setFieldsValue(obj)
          }
        })
      },
      setOperatorType (type) {
        this.operatorType = type
      },
      setBeanInfo (beanInfo) {
        // todo
      },
      resetFields () {
        // todo
      }


    },

  }
</script>


